﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BuildPlannerLib.Buildings;
using BuildPlannerLib.Terran.Enums;

namespace BuildPlannerLib.Terran.Buildings
{
    // Derived class from EnergyBuilding for Command Centers
    public class IndividualCommandCenter : EnergyBuilding
    {
        // CommandCenterUpgrade enum property for upgrade status of the Command Center
        private CommandCenterUpgrade upgradeStatus;
        public CommandCenterUpgrade UpgradeStatus
        {
            get { return upgradeStatus; }
            set { upgradeStatus = value; }
        }

        // Boolean property for whether the Command Center is floating to a new location
        private bool floating;
        public bool Floating
        {
            get { return floating; }
            set { floating = value; }
        }
        
        // Constructor with a parameter for base location
        public IndividualCommandCenter(int atbase)
        {
            UpgradeStatus = CommandCenterUpgrade.BasicCC;
            AtBase = atbase;
            TargetBase = atbase;
        }

        // Starts converting the Command Center into an Orbital Command
        public void StartConvert(CommandCenterUpgrade upgrade)
        {
            InUse = true;

            switch (upgrade)
            {
                case CommandCenterUpgrade.OrbitalCommand:
                    UpgradeStatus = CommandCenterUpgrade.UpgradingToOC;
                    break;
                case CommandCenterUpgrade.PlanetaryFortress:
                    UpgradeStatus = CommandCenterUpgrade.UpgradingToPF;
                    break;
            }
        }

        // Finishes converting the Command Center into an Orbital Command
        public void FinishConvert(CommandCenterUpgrade upgrade)
        {
            UpgradeStatus = upgrade;
            if (upgrade == CommandCenterUpgrade.OrbitalCommand)
                Energy = new ResourceWithMaximum(50, 200);
            InUse = false;
        }

        public void StartFloating()
        {
            Floating = true;
            InUse = true;
        }

        public void FinishFloating(int newBase)
        {
            Floating = false;
            InUse = false;
            AtBase = newBase;
            TargetBase = newBase;
        }
    }
}
